import { reactive, ref } from 'vue';
import router from '@/router';

export default function importConfig(props) {
  const { user } = props;
  const base = reactive<any>({
    passwordFormRef: null,
  });

  const passwordForm = reactive({
    oldPassword: null,
    newPassword: null,
    confirmPassword: null,
  });

  const passwordRules = {
    oldPassword: [{ required: true, message: '请输入旧密码' }],
    newPassword: [{ required: true, message: '请输入新密码' }],
    confirmPassword: [{ required: true, message: '请确认密码' }],
  };

  const passwordList = [
    {
      label: '旧密码',
      placeholder: '请输入旧密码',
      field: 'oldPassword',
    },
    {
      label: '新密码',
      placeholder: '请输入新密码',
      field: 'newPassword',
    },
    {
      label: '确认密码',
      placeholder: '请确认密码',
      field: 'confirmPassword',
    },
  ];

  const save = () => {
    base.passwordFormRef.validate((res) => {
      if (!res) {
        // console.log('2验证通过');
      }
    });
  };

  const close = () => {
    router.replace('/home');
  };

  return {
    base,
    passwordRules,
    passwordForm,
    passwordList,
    save,
    close,
  };
}
